; This program makes pipe template blocks for chest layouts. ; It is metric, you may need to make some changes for inch drawings. ; To use, copy into your \ACAD directory and while inside Autocad, ; type -> (load"Make metal pipe templates") ; If you like, just give the "C"s (or any other interval), it will ; calculate the pipes in-between. ; rev: May 30/93 (prompt (strcat (chr 13) (chr 10) "Loading metal pipe template file...")) (defun dtr (a) (* pi (/ a 180.0))); converts degrees to radians (defun maketemp (pno) (setq wpt1 (polar pt (dtr 225.0) (/ d 1.5)) wpt2 (polar pt (dtr 45.0) (/ d 1.5)) bn (strcat mark "-" (itoa pno)) th (/ d 7) ) ; draw circle (command "LAYER" "SET" "Pipe-Template" "") (command "CIRCLE" pt "D" d) (command "CHANGE" "L" "" "P" "C" colour "") ; draw target (command "LAYER" "SET" "Pipe-Template-Center" "") (command "LINE" (list (- (car pt) 5) (+ (cadr pt) 5)) (list (+ (car pt) 5) (- (cadr pt) 5)) "") (command "LINE" (list (+(car pt) 5) (+ (cadr pt) 5)) (list (-(car pt) 5) (- (cadr pt) 5)) "") ;now we add some text (command "LAYER" "S" "Pipe-Template-Name" "") (command "STYLE" "TEMPLATE" "" th "" "" "" "" "") (command "TEXT" "C" (list (car pt) (+ (cadr pt) (/ d 8))) "0" mark) (command "TEXT" "C" (list (car pt) (- (cadr pt) (/ d 4))) "0" pno ) (command "LAYER" "SET" "0" "") ; and block it (command "BLOCK" bn pt "C" wpt1 wpt2 "") ) (defun c:TEMPLATE () ; Variables: ; Mark string stop label ; pt point location to draw temporary templates ; tn int number of first template ; tncur int number of current template ; tnxt int number of next template ; d real diameter of first template ; dnxt real diameter of next template ; factor real multiply by d to get dnxt ; th real height of lettering ; Save Environment & Initialize (setq cmdechofound (getvar "CMDECHO") hilitefound (getvar "HIGHLIGHT") osfound (getvar "OSMODE") regenfound (getvar "REGENMODE") clayerfound (getvar "CLAYER") ) (setvar "CMDECHO" 0) (setvar "OSMODE" 0) (setvar "REGENMODE" 0) (setvar "HIGHLIGHT" 0) ; Get the First Template (setq mark (getstring "Enter the name for this stop (up to 5 characters, eg. Trp8): ")) (setq colour (getstring "Color for this set: ")) ; Let's make sure we've got the layers (command "STYLE" "TEMPLATE" "SIMPLEX" "1" ".75" "0" "" "" "") (command "LAYER" "N" "Pipe-Template" "C" colour "Pipe-Template" "T" "Pipe-Template-Center" "") (command "LAYER" "N" "Pipe-Template-Center" "C" colour "Pipe-Template-Center" "T" "Pipe-Template-Center" "") (command "LAYER" "N" "Pipe-Template-Name" "C" Colour "Pipe-Template-Name" "T" "Pipe-Template-Name" "T" "0" "S" "0" "") (setq pt (getpoint (strcat "Select blank location on screen to build templates: " (chr 13) (chr 10)))) (setq tn (getint "Pipe number for first template (e.g. 1): ")) (setq d (getreal (strcat "Diameter (in mm) for template number " (itoa tn) ": "))) (maketemp tn); make the template (setq tnxt (getint "Pipe number for next template: ")) ; Loop for the Remaining Templates (while (not (equal tnxt nil)) (setq dnxt (getreal (strcat "Diameter (in mm) for template number " (itoa tnxt) ": "))) (setq factor (expt (/ dnxt d) (/ 1.0 (- (float tnxt) (float tn))))) (setq tncur (+ tn 1)) (while (<= tncur tnxt) (setq d (* factor d)) (maketemp tncur) (setq tncur (1+ tncur)) ) (setq tn tnxt) (setq tnxt (getint "Number for next template: ")) ) ; restore environment (command "LAYER" "SET" clayerfound "") (setvar "OSMODE" osfound) (setvar "REGENMODE" regenfound) (setvar "HIGHLIGHT" hilitefound) (setvar "CMDECHO" cmdechofound) (princ) ) (prompt (strcat "loaded." (chr 13) (chr 10))) (c:TEMPLATE)